<?php
require_once '../include/common.inc.php';
require_once AK_ROOT.'include/admin.inc.php';
require_once 'custom.config.php';
ak_copy(AK_ROOT.'install/trunk', FORE_ROOT);
ak_copy(AK_ROOT.'install/templates', AK_ROOT.'configs/templates/ak');
if(file_exists(AK_ROOT.'install/plugins')) ak_copy(AK_ROOT.'install/plugins', AK_ROOT.'plugins');
$files = readpathtoarray(AK_ROOT.'install/db');
foreach($files as $file) {
	$data = readfromfile($file);
	$rows = explode("\n", $data);
	$tables = array();
	foreach($rows as $row) {
		if($row == '') continue;
		$value = unserialize(base64_decode($row));
		if(!in_array($value['table'], $tables)) {
			if(trim($value['table']) == '') continue;
			$tables[] = $value['table'];
			$db->query("DELETE FROM {$value['table']}");
		}
		$db->insert($value['table'], $value['value']);
	}
}
updatecache();
header('location:../login.php');
aexit();
?>